<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

        /* ul li  后代选择器  */
        /* ul>li  子代选择器 */

        .list {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        /* 除了第一个li没有margin-top,其余的li都有 */
        .list>li {
            width: 100%;
            height: 40px;
            border: 2px solid #ddd;
            /* margin-top: 10px; */
            overflow: hidden;
            transition: .5s linear;
        }

        /* .list li:first-child {
            margin-top: 0;
        } */

        .list>li + li {
            margin-top: 10px;
        }

        .default-text {
            height: 40px;
        }

        .dropdown-list {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .dropdown-list > li {
            width: 100%;
            height: 30px;
            background: #ddd;
            border: 1px solid #000;
            box-sizing: border-box;
        }
    </style>
</head>
<body>
    <ul class="list">
        <li>
            <div class="default-text">一致性Consistency</div>

            <ul class="dropdown-list">
                <li>折叠面板1</li>
                <li>折叠面板2</li>
                <li>折叠面板3</li>
                <li>折叠面板4</li>
                <li>折叠面板5</li>
                <li>折叠面板6</li>
                <li>折叠面板7</li>
                <li>折叠面板8</li>
                <li>折叠面板9</li>
            </ul>
        </li>
        <li>
            <div class="default-text">反馈Consistency</div>
        </li>
        <li>
            <div class="default-text">效率Consistency</div>
        </li>
        <li>
            <div class="default-text">可控Consistency</div>
        </li>
    </ul>

    <script>
        // 事件捕获
        var lis = document.querySelectorAll('.list>li')

        console.log(lis)
        for (var i = 0; i < lis.length; i++) {
            lis[i].onclick = function (event) {
                console.log(event.target)
                // console.log(event.target.parentNode)

                var dropdownListHeight = event.target.nextElementSibling.children.length * 30

                console.log((40 + dropdownListHeight))
                console.log(parseFloat(event.target.parentNode.style.height))
                console.log(typeof event.target.parentNode.style.height)

                if (parseFloat(event.target.parentNode.style.height) === 40 || !parseFloat(event.target.parentNode.style.height)) {
                    event.target.parentNode.style.height = (40 + dropdownListHeight) + 'px'
                } else {
                    event.target.parentNode.style.height = 40 + 'px'
                }

                // console.log(event.target.nextElementSibling)
                // console.log(event.target.nextElementSibling.childNodes)
                // console.log(event.target.nextElementSibling.children)

                // console.log(this.nextElementSibling)
            }
        }
    </script>
</body>
</html>